package cn.tedu.straw.gateway.controller;


import cn.tedu.straw.commons.security.UserInfo;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @author shkstart
 * @create 2020-07-18 14:25
 */
@Controller
public class SystemController {

    @GetMapping("/register.html")
    public String register(){
        return "register";
    }

    @GetMapping("/login.html")
    public  String login(){
        return "login";
    }

//    适用于RestController时
//    public  ModelAndViewlogin(){
//        return new ModelAndView("login");
//    }

    @GetMapping("/question/create.html")
    public String createQuestion(){
        return "question/create";
    }

    @GetMapping("/question/detail.html")
    public String questionQuestion(){
        return "question/detail";
    }
    @GetMapping("/index.html")
    public String index(@AuthenticationPrincipal UserInfo userInfo) {
        if (userInfo.getType() == 0) {
            return "index";
        } else {
            return "index_teacher";
        }
    }
    @GetMapping("/personal/collect.html")
    public String UserCottlection(){

        return "/question/collect";
    }

    @GetMapping("/personal/myQuestion.html")
    public String a(@AuthenticationPrincipal UserInfo userInfo) {
        if (userInfo.getType() == 0) {
            return "myQuestion.html";
        } else {
            return "index_teacher";
        }
    }
}
